package components.dialogs
{
	import UIFree.ObjectEvent;
	import UIFree.components.uif_window;
	
	import classes.c_events;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;

	public dynamic class c_elemDlgList extends Array {
		private var _workspace: EventDispatcher;
		public function c_elemDlgList(a_workspace: EventDispatcher) {
			super();
			_workspace = a_workspace;
			_workspace.addEventListener(c_events.ELEMDLGCLSEALL, doCloseAll);
		}
		
		private function doCloseAll(e: Event): void {
			forEach(function(dlg: c_elementPropDlg, i: int, arr: Array): void {
				dlg.close();
			});
		}
		
		public function pushDlg(dlg: c_elementPropDlg): void {
			push(dlg);
			_workspace.dispatchEvent(new ObjectEvent(c_events.ELEMDLGLIST, this));
		}
		
		public function deleteDlg(dlg: c_elementPropDlg): void {
			var m_index: int = indexOf(dlg);
			if (m_index > -1) {
				splice(m_index, 1);
				_workspace.dispatchEvent(new ObjectEvent(c_events.ELEMDLGLIST, this));
			}
		}
	}
}